<?php
/**
 * Copyright (c) 2006-2007, Julien PORTALIER
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright    Copyright (c) 2006-2007, Julien PORTALIER
 * @link         http://featherphp.googlecode.com/
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Handles errors.
 */
class ErrorsController extends Controller
{
	public $uses       = null;
	public $layout     = 'error';
	public $_templates = 'errors';
	protected $codes;
	
	function index($status=404, $action=null)
	{
		$this->data['code'] = $status;
		$this->data['name'] = $this->__code($status);
		$this->pageTitle    = preg_replace(':^HTTP/1.1 \d+ :', '', $this->data['name']);
		$this->render(empty($action) ? $status : $action);
	}
	
	protected function __code($status)
	{
		if (empty($this->codes))
			$this->codes = parse_ini_file(FEATHER.'config'.DS.'status.ini.php');
		header($this->codes[$status]);
		return $this->codes[$status];
	}
}
?>